package everydayone.climbStairs;
/**
 * @date 2020/06/13
 * @author 王光浩 
 * @thinking 使用 DP
 * @Analysis 时间复杂度O（n），空间复杂度O（1）
 */
public class MyMethodTwo {
	public int climbStairs(int n) {
		if (n <= 2)
			return n;
		int first = 1;
		int second = 2;
		int ret = 0;
		for (int i = 3; i <= n; i++) {
			ret = second + first;
			first = second;
			second = ret;
		}
		return ret;
	}
}
